<div id="data_page" class="in_page">
  <div class="panel panel-default">
  <div class="panel-body">
   <form class="form-inline" method="get" id="register" onsubmit="check()">
    <div class="form-group">
      <label for="keyword" >搜索</label>
      <input type="text"  name="keyword" id="keyword" placeholder="客服编号"  value="{$whereArr.keyword}" >
      开始时间:<input type="date" id="starttime" name="starttime" value="{$whereArr.starttime}" />
      结束时间:<input type="date" id="endtime" name="endtime" value="{$whereArr.endtime}"  />
      
     <!-- <select id="type" name="type">
        <option value="">请选择服务类型</option>
        <volist name="list_key" id="arr">
        <option <if condition="$whereArr['type'] eq $arr['title']"> selected="selected" </if> value="{$arr.title}">{$arr['title']}</option>
        </volist> 
      </select>-->
       
      <select id="wancheng" name="wancheng">
        <option value="">是否完成</option> 
        <option value="1" <if condition="$whereArr['wancheng'] eq 1"> selected="selected" </if>>未完成</option>
        <option value="2" <if condition="$whereArr['wancheng'] eq 2"> selected="selected" </if>>已完成</option>
      
      </select>
    </div>
      <button type="button" id="sub" d_url="service_list" class="btn btn-sm btn-default fBtn">查找</button>
      <button type="button" id="export" d_url="exportcsv" class="btn btn-sm btn-default fBtn">导出</button>
</form>
  </div>
</div>
      <table class="table table-bordered" style="text-align:center">
        <thead>
          <tr>
           <!--  <th><span class="glyphicon glyphicon-leaf"></span>ID</th> -->
            <th><span class="glyphicon glyphicon-leaf"></span>服务对象</th>
            <th><span class="glyphicon glyphicon-leaf"></span>服务对象联系方式</th>
           <!-- <th><span class="glyphicon glyphicon-leaf"></span>服务类型</th>-->
            <th><span class="glyphicon glyphicon-leaf"></span>服务时间</th>
             <th><span class="glyphicon glyphicon-leaf"></span>评价</th>
            <th><span class="glyphicon glyphicon-leaf"></span>客服编号</th>
            <th><span class="glyphicon glyphicon-leaf"></span>客服姓名</th>
            <th><span class="glyphicon glyphicon-leaf"></span>完成状况</th>
            <th><span class="glyphicon glyphicon-leaf"></span>备注</th>
            <th><span class="glyphicon glyphicon-leaf"></span>查看聊天记录</th>
            <th><span class="glyphicon glyphicon-leaf"></span>导出本次聊天记录</th>
          </tr>     
        </thead>
        <tbody>
         <volist name="list['list']" id="data">
          <tr>
            <td>{$data['user']}</td>
            <td>{$data['phone']}</td>
           <!-- <td>{$data['key']}</td>        --> 
            <td><?php echo date('Y-m-d H:i:s',$data['created']); ?></td>    
             <td>{$data['ping_jia']}</td>         
            <td>{$data['kf_account']}</td>
            <td>{$data['kf_name']}</td>
            <td class="wancheng" did="{$data['id']}">
            未完成<input type="radio" name="wan_{$data['id']}" value="1" <if condition="$data['sta'] eq '1'"> checked="checked"</if>  />
            已完成<input type="radio" name="wan_{$data['id']}"  value="2" <if condition="$data['sta'] eq '2'"> checked="checked"</if> />
            </td>
    				
            <th> 
              <?php
                if($data['beizhu']==""){
              ?>

 <a href="{:U('Customer/add_bei_index')}?id={$data['id']}&fw_name={$data['user']}&ctime={$data['created']}"> <button type="button" class="btn btn-primary btn-xs">添加备注</button></a>

              <?php } ?>
              <?php
                if($data['beizhu']!=""){
              ?>
 <a href="{:U('Customer/bei_index')}?id={$data['id']}&fw_name={$data['user']}&ctime={$data['created']}"> <button type="button" class="btn btn-primary btn-xs">查看备注</button></a>

              
              <?php } ?>
  
              
            </th>
            <th>
 						<a href="{:U('Customer/talk_log')}?id={$data['id']}"> <button type="button" class="btn btn-primary btn-xs">查看记录</button></a>
            </th>
             <th>
 						<a href="{:U('Customer/export_talk_log')}?id={$data['id']}"> <button type="button" class="btn btn-primary btn-xs">导出聊天记录</button></a>
            </th>
          <!--   <td>{$data['email']}</td>
          <td>{$data['birth']}</td> -->
          </tr>
        </volist>
        </tbody>
      </table> 
</div>
<div class="pagelist">{$list['page']} </div>
<style>
.pagelist{ text-align:right; background:#f1f1f1; padding:7px 0;}
.pagelist a{ margin:0 5px; border:#6185a2 solid 1px; display:inline-block; padding:2px 6px 1px; line-height:16px; background:#fff; color:#6185a2;}
.pagelist span{ margin:0 5px; border:#6185a2 solid 1px; display:inline-block; padding:2px 6px 1px; line-height:16px; color:#6185a2; color:#fff; background:#6185a2;}
.trr td{height: 50px; line-height: 50px}
</style>    
<script type="text/javascript">

	function check(){
		var starttime=$("#starttime").val();
		var endtime=$("#endtime").val();
		if(starttime > endtime && starttime.length>0 && endtime.length>0 ){
			alert('结束时间必须大于开始时间');
			return false;
		}
		return true;
	}
	$(".wancheng").click(function(){
		var value= $('.wancheng input:radio:checked').val();
		var xiu_id=$(this).attr("did");
		var data={
			wancheng:value,
			id:xiu_id,
		}
		//var a=JSON.stringify(data);
		
		//alert(xiu_id);
		$.post('{:U("Customer/wancheng")}',data,function(obj){
			if(obj.s=="ok"){
				alert(obj.m);
			}else{
				alert("不可修改重复的");
			}
			
		});
		
	});
	
	$('.fBtn').click(function(){
		var r = check();
		if(!r) return false;
		
		$('#register').attr('action','{:U("Customer/'+ $(this).attr('d_url') +'")}');
		$('#register').submit();
	});
	
	/*
	$("#sub").click(function(){
		var r = check();
		if(!r) return false;
		
		$('#register').attr('action','{:U("Customer/service_list")}');
		$('#register').submit();
		
	});
	$("#export").click(function(){
		var r = check();
		if(!r) return false;
		
		$('#register').attr('action','{:U("Customer/exportcsv")}');
		$('#register').submit();
		 
		var url = '{:U("Customer/exportcsv")}?';
		var keyword = $('#keyword').val();
		if(keyword.length>0){
			url += 'keyword='+keyword+'&';
		} 
		var type = $('#type').val();
		if(type.length>0){
			url += 'type='+type+'&';
		} 
		var starttime = $('#starttime').val();
		if(starttime.length>0){
			url += 'starttime='+starttime+'&';
		} 
		var endtime = $('#endtime').val();
		if(endtime.length>0){
			url += 'endtime='+endtime+'&';
		} 
		
		var wancheng = $('#wancheng').val();
		if(wancheng.length>0){
			url += 'wancheng='+wancheng+'&';
		} 
		
		window.open(url);
	});
		*/
</script>  